import axios from 'axios';

const service = axios.create({
  baseURL: 'http://127.0.0.1:4523/m1/5546336-5223294-default',
  timeout: 5000
});

// 请求拦截器
service.interceptors.request.use(
  config => {
    console.log('Request URL:', config.baseURL + config.url);
    console.log('Request Params:', config.params);
    return config;
  },
  error => {
    console.error('Request Error:', error);
    return Promise.reject(error);
  }
);

// 响应拦截器
service.interceptors.response.use(
  response => {
    console.log('Response Structure:', {
      status: response.status,
      headers: response.headers,
      data: response.data
    });
    return response.data;  // 直接返回 response.data
  },
  error => {
    console.error('Response Error:', error);
    return Promise.reject(error);
  }
);

export default service;
